package com.liuyjy.mybatisplus.util;

/**
 * @Author liuyjy
 * @Date 2022/2/28 9:19
 * @Description: id生成器
 **/
public class IdUtil {

    /**
     * 获取19位id
     *
     * @return id
     */
    public synchronized static Long getId() {
        long currentTimeMillis = System.currentTimeMillis();
        long nanoTime = System.nanoTime();
        System.out.println("获取纳秒时间戳：" + (currentTimeMillis * 1000000L + nanoTime / 100 % 1000000L));
        return currentTimeMillis * 1000000L + nanoTime / 100 % 1000000L;
    }

    public static void main(String[] args) {
        System.out.println(getId());
    }
}
